home *** CD-ROM | disk | FTP | other *** search
- /*
- File: AEHelpers.h
-
- Contains: Functions to help you when you are building and sending Apple events.
-
- Written by: Andy Bachorski
-
- Copyright: Copyright © 1996-1999 by Apple Computer, Inc., All Rights Reserved.
-
- You may incorporate this Apple sample source code into your program(s) without
- restriction. This Apple sample source code has been provided "AS IS" and the
- responsibility for its operation is yours. You are not permitted to redistribute
- this Apple sample source code as "Apple sample source code" after having made
- changes. If you're going to re-distribute the source, we require that you make
- it clear in the source that the code was descended from Apple sample source
- code, but that you've made changes.
-
- Change History (most recent first):
- 7/21/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1
-
-
- */
-
- #if PRAGMA_ONCE
- #pragma once
- #endif
-
- #ifndef AEHELPERS
- #define AEHELPERS
-
-
- //••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
-
- // A private conditionals file to setup the build environment for this project.
-
- #include "PrivateConditionals.h"
-
-
- //******************************************************************************
-
- // System includes
- #include <AERegistry.h>
- #include <AEObjects.h>
- #include <AEPackObject.h>
- #include <EPPC.h>
- #include <Gestalt.h>
- #include <Processes.h>
-
-
- //******************************************************************************
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
-
- //******************************************************************************
-
- OSErr AEHMakeEventSelfTarget( AEEventClass eventClass,
- AEEventID eventID,
- AppleEvent *eventPtr );
- /*
- Create and return an AppleEvent of the given class and ID. The event will be
- targeted at the current process, with an AEAddressDesc of type
- typeProcessSerialNumber.
-
- eventClass input: The class of the event to be created.
- eventID input: The ID of the event to be created.
- eventPtr input: Pointer to an AppleEvent where the
- event record will be returned.
- output: The Apple event.
-
- RESULT CODES
- ____________
- noErr 0 No error
- memFullErr -108 Not enough room in heap zone
- ____________
- */
- //******************************************************************************
-
- pascal OSErr AEHMakeEventSignatureTarget( OSType targetType,
- OSType targetCreator,
- AEEventClass eventClass,
- AEEventID eventID,
- AppleEvent *theEvent );
- /*
- Create and return an AppleEvent of the given class and ID. The event will be
- targeted at the process specified by the target type and creator codes,
- with an AEAddressDesc of type typeProcessSerialNumber.
-
- targetType input: The file type of the process to be found.
- targetCreator input: The creator type of the process to be found.
- eventClass input: The class of the event to be created.
- eventID input: The ID of the event to be created.
- theEvent input: Pointer to an AppleEvent where the
- event record will be returned.
- output: The Apple event.
-
- RESULT CODES
- ____________
- noErr 0 No error
- memFullErr -108 Not enough room in heap zone
- procNotFound –600 No eligible process with specified descriptor
- ____________
- */
-
- //******************************************************************************
-
- pascal OSErr AEHMakeEventProcessTarget( const ProcessSerialNumberPtr psnPtr,
- AEEventClass eventClass,
- AEEventID eventID,
- AppleEvent *theEvent );
- /*
- Create and return an AppleEvent of the given class and ID. The event will be
- targeted with the provided PSN.
-
- psnPtr input: Pointer to the PSN to target the event with.
- eventClass input: The class of the event to be created.
- eventID input: The ID of the event to be created.
- theEvent input: Pointer to an AppleEvent where the
- event record will be returned.
- output: The Apple event.
-
- RESULT CODES
- ____________
- noErr 0 No error
- memFullErr -108 Not enough room in heap zone
- procNotFound –600 No eligible process with specified descriptor
- ____________
- */
-
- //******************************************************************************
-
- pascal OSErr AEHMakeEventTargetID( const TargetID *targetIDPtr,
- AEEventClass eventClass,
- AEEventID eventID,
- AppleEvent *theEvent );
- /*
- Create and return an AppleEvent of the given class and ID. The event will be
- targeted with the provided TargetID.
-
- targetIDPtr input: Pointer to the TargetID to target the event with.
- eventClass input: The class of the event to be created.
- eventID input: The ID of the event to be created.
- theEvent input: Pointer to an AppleEvent where the
- event record will be returned.
- output: The Apple event.
-
- RESULT CODES
- ____________
- noErr 0 No error
- memFullErr -108 Not enough room in heap zone
- procNotFound –600 No eligible process with specified descriptor
- ____________
- */
-
- //******************************************************************************
-
- pascal OSErr AEHSendEventReturnSInt16( const AEIdleUPP idleProcUPP,
- const AppleEvent *theEvent,
- SInt16 *theValue );
- /*
- Send the provided AppleEvent using the provided idle function.
- Return a SInt16 (typeSmallInteger).
-
- idleProcUPP input: The idle function to use when sending the event.
- theEvent input: The event to be sent.
- theValue output: The value returned by the event.
-
- RESULT CODES
- ____________
- noErr 0 No error
- paramErr -50 No idle function provided
-
- and any other error that can be returned by AESend or the handler
- in the application that gets the event.
- ____________
- */
-
- //******************************************************************************
-
- pascal OSErr AEHSendEventNoReturnValue( const AEIdleUPP idleProcUPP,
- const AppleEvent *theEvent );
- /*
- Send the provided AppleEvent using the provided idle function.
- Will wait for a reply if an idle function is provided, but no result will be returned.
-
- idleProcUPP input: The idle function to use when sending the event.
- theEvent input: The event to be sent.
-
- RESULT CODES
- ____________
- noErr 0 No error
-
- and any other error that can be returned by AESend or the handler
- in the application that gets the event.
- ____________
- */
-
- //******************************************************************************
-
- pascal OSErr AEHGetHandlerError( const AppleEvent *reply );
- /*
- Takes a reply event checks it for any errors that may have been returned
- by the event handler. A simple function, in that it only returns the error
- number. You can often also extract an error string and three other error
- parameters from a reply event.
-
- Also see:
- IM:IAC for details about returned error strings.
- AppleScript developer release notes for info on the other error parameters.
-
- reply input: The reply event to be checked.
-
- RESULT CODES
- ____________
- noErr 0 No error
- ???? ?? Pretty much any error, depending on what the
- event handler returns for it's errors.
- */
-
- //******************************************************************************
-
- OSErr AEHExtractClassAndID ( const AppleEvent *eventPtr,
- AEEventClass *eventClass,
- AEEventID *eventID );
- /*
- Get the class and ID from an AppleEvent.
-
- eventPtr input: The event to get the class and ID from.
- eventClass output: The event's class.
- eventID output: The event's ID.
-
- RESULT CODES
- ____________
- noErr 0 No error
- memFullErr -108 Not enough room in heap zone
- errAEDescNotFound -1701 Descriptor record was not found
- errAENotAEDesc -1704 Not a valid descriptor record
- errAEReplyNotArrived -1718 Reply has not yet arrived
- */
-
- //******************************************************************************
-
- pascal Boolean AEHSimpleIdleFunction( EventRecord *event,
- long *sleepTime,
- RgnHandle *mouseRgn );
- /*
- A very simple idle function. It simply ignors any event it receives,
- returns 30 for the sleep time and nil for the mouse region.
-
- Your application should supply an idle function that handles any events it
- might receive. This is especially important if your application has any windows.
-
- Also see:
- IM:IAC for details about idle functions.
- Pending Update Perils technote for more about handling low-level events.
- */
-
- //******************************************************************************
-
- pascal Boolean GestaltAvailable( void );
- /*
- Is the Gestalt trap present.
-
- RESULT CODES
- ____________
- true Gestalt is present
- false It isn't
- */
-
- //******************************************************************************
-
- pascal Boolean HasAppleEvents( void );
- /*
- Is the Apple Event Manager present.
-
- RESULT CODES
- ____________
- true The Apple Event Manager is present
- false It isn't
- */
-
- //******************************************************************************
-
- pascal Boolean FinderCallsAEProcess( void );
- /*
- Does the Finder call AEProcessAppleEvent when it receives an Apple event.
-
- RESULT CODES
- ____________
- true Finder is version 7.1.3 or later, calls AEProcessAppleEvent,
- and supports the full old Finder event suite.
- false The Finder supports a subset of the old Finder event suite.
-
- Use this routine together with FinderIsOSLCompliant to determine which
- suite of events the Finder supports.
- */
-
- //******************************************************************************
-
- pascal Boolean FinderIsOSLCompliant( void );
- /*
- Does the Finder uses the ObjectSupportLib to resolve objecs.
-
- RESULT CODES
- ____________
- true Finder is version 7.5 or later, and supports the Standard event suite,
- the new Finder event suite & a subset of the old Finder event suite.
- false See result of FinderCallsAEProcess.
-
- Support for the old Finder event suite is limited, with some events missing
- and some events only partially supported. The subset of old Finder event
- supported is not the same subset as the original Finder 7 supported.
-
- Use the new event suite, and avoid the old one, whenever possible.
- */
-
- //******************************************************************************
-
- pascal Boolean FinderUsesIconFamily( void );
- /*
- Does the Finder uses cIconFamily records or IconSuites.
-
- So far (as of Mac OS 8.1) only the Finder in Mac OS 8.0 requires the use of
- IconSuites, rather than cIconFamily like the other Finders. This test
- lets us identify this odd Finder so we can special case Icon code.
-
- RESULT CODES
- ____________
- true Finder uses cIconFamily.
- false Finder uses IconSuite.
- */
-
- //******************************************************************************
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif// AEHELPERS
-